/*
-------------------------------------------------

	Texture.h

	Dmitriy Kuzmenko (Dgut)

-------------------------------------------------
*/

#ifndef __AUTUMN_TEXTURE_H__
#define __AUTUMN_TEXTURE_H__

#include "OpenGL.h"

namespace Autumn
{

class PNG;

class Texture
{
protected:
	GLuint							id;
public:
									Texture( void );
	virtual							~Texture( void );

	inline const GLuint				GetID( void ) const;
	virtual inline const GLenum		GetTarget( void ) const = 0;

	inline void						Bind( void ) const;

	inline void						Parameter( GLenum pname, GLint param );
	inline void						Parameter( GLenum pname, GLfloat param );
	inline void						Parameter( GLenum pname, const GLint * params );
	inline void						Parameter( GLenum pname, const GLfloat * params );
};

inline const GLuint Texture::GetID( void ) const
{
	return id;
}

inline void Texture::Bind( void ) const
{
	glBindTexture( GetTarget(), id );
}

inline void Texture::Parameter( GLenum pname, GLint param )
{
	glTexParameteri( GetTarget(), pname, param );
}

inline void Texture::Parameter( GLenum pname, GLfloat param )
{
	glTexParameterf( GetTarget(), pname, param );
}

inline void Texture::Parameter( GLenum pname, const GLint * params )
{
	glTexParameteriv( GetTarget(), pname, params );
}

inline void Texture::Parameter( GLenum pname, const GLfloat * params )
{
	glTexParameterfv( GetTarget(), pname, params );
}

class Texture2D : public Texture
{
public:
									Texture2D( void );
	virtual							~Texture2D( void );

	virtual inline const GLenum		GetTarget( void ) const;

	void							Image( GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels );
	void							Image( const PNG * png );

	static Texture2D * const		CreateStandart( const char * fileName );
};

inline const GLenum Texture2D::GetTarget( void ) const
{
	return GL_TEXTURE_2D;
}

}	// namespace Autumn

#endif	// !!! __AUTUMN_TEXTURE_H__ !!!